<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let str = `12:21`;

        let a = '\\d\\d:';
        let b = '\\d\\d';

        const reg = new RegExp(`${a}${b}`, 'g');
        console.log(str.match(reg));
        console.log(str.match(/\d\d:\d\d/g));



    </script>
</body>

</html>